home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
MACD 5
/
MACD 5.bin
/
workbench
/
blankery
/
blanker
/
source
/
blankers
/
clock
/
blank.c
next >
Wrap
C/C++ Source or Header
|
1993-08-15
|
4KB
|
148 lines
#include <exec/types.h>
#include <exec/memory.h>
#include <dos/dos.h>
#include <dos/datetime.h>
#include <intuition/intuition.h>
#include <intuition/screens.h>
#include <clib/exec_protos.h>
#include <clib/graphics_protos.h>
#include <clib/intuition_protos.h>
#include <clib/dos_protos.h>
#include <clib/diskfont_protos.h>
#include <clib/utility_protos.h>
#include <clib/alib_protos.h>
#include <stdio.h>
#include "Clock.h"
#include "/defs.h"
#include "/utility.h"
struct cPrefObject {
UBYTE fName[64], Speed, Cycle, Secs, Military;
struct TextAttr Font;
};
extern struct cPrefObject nP;
extern ULONG Depth, Mode;
extern UBYTE *prefData;
int getTime( UBYTE *time, struct cPrefObject *nP )
{
struct DateTime dt;
ULONG h,m,s;
CopyMem( DateStamp( &dt.dat_Stamp ), &dt.dat_Stamp, sizeof( struct DateStamp ));
dt.dat_StrDay = 0L;
dt.dat_StrDate = 0L;
dt.dat_StrTime = time;
if( !DateToStr( &dt )) time[0] = 0;
else {
sscanf( time, "%d:%d:%d", &h, &m, &s );
if( nP->Military ) {
if( nP->Secs ) {
sprintf( time, "%d:%02d:%02d", h, m, s );
return(( h > 9 )?8:7 );
} else {
sprintf( time, "%d:%02d", h, m );
return(( h > 9 )?5:4 );
}
} else {
if( nP->Secs ) {
sprintf( time, "%d:%02d:%02d%s", (!h?12:(h%13)+(h/13)), m, s, h>11?"pm":"am" );
return(( h%13 > 8 )?10:9 );
} else {
sprintf( time, "%d:%02d%s", (!h?12:(h%13)+(h/13)), m, h>11?"pm":"am" );
return(( h%13 > 8 )?7:6 );
}
}
}
}
VOID blank( VOID )
{
struct TextFont *font;
struct cPrefObject *bP;
struct Screen *Scr;
UBYTE vals[] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4,
3, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 };
UBYTE scrClock[128], c1 = 0, c2 = 14, c3 = 28;
ULONG x, y, Wid, Hei, len, nlen, numc, base, count = 0;
LONG dx = 1, dy = 1;
if( ClockWnd ) bP = &nP;
else bP = ( struct cPrefObject * )prefData;
bP->Font.ta_Name = bP->fName;
font = OpenDiskFont( &( bP->Font ));
base = font->tf_Baseline;
Scr = OpenScreenTags( 0l, SA_DisplayID, Mode, SA_Depth, 1, SA_Quiet, TRUE, SA_Behind, TRUE, SA_Overscan,
OSCAN_STANDARD, SA_Font, &( bP->Font ), TAG_DONE );
Wid = Scr->Width;
Hei = Scr->Height;
SetRGB4( &(Scr->ViewPort), 0, 0L, 0L, 0L );
switch( bP->Cycle ) {
case 0:
SetRGB4( &(Scr->ViewPort), 1, vals[c1], vals[c2], vals[c3] );
break;
case 1:
SetRGB4( &(Scr->ViewPort), 1, VBeamPos()%15 + 1, VBeamPos()%15 + 1, VBeamPos()%15 + 1 );
break;
case 2:
SetRGB4( &(Scr->ViewPort), 1, 15, 15, 15 );
break;
case 3:
setCopperList( Hei, 1, &( Scr->ViewPort ));
break;
}
numc = getTime( scrClock, bP );
while(( len = TextLength( &(Scr->RastPort), scrClock, numc )) >= Wid ) numc--;
x = VBeamPos()%( Wid - len - 1 ) + 1;
y = VBeamPos()%( Hei - bP->Font.ta_YSize - 1 ) + 1;
SetAPen( &(Scr->RastPort), 1 );
Move( &(Scr->RastPort), x, y + base );
Text( &(Scr->RastPort), scrClock, numc );
BlankMousePointer();
ScreenToFront( Scr );
while(!( SetSignal( 0L, 0L )&SIGBREAKF_CTRL_C )) {
WaitTOF();
if( !bP->Cycle ) if( !(++count%10 )) SetRGB4( &(Scr->ViewPort), 1, vals[c1 = ++c1%42],
vals[c2 = ++c2%42], vals[c3 = ++c3%42] );
numc = getTime( scrClock, bP );
while(( nlen = TextLength( &(Scr->RastPort), scrClock, numc ))+x > Wid ) numc--;
Move( &(Scr->RastPort), x, y + base );
Text( &(Scr->RastPort), scrClock, numc );
if( nlen < len ) {
SetAPen( &(Scr->RastPort), 0 );
RectFill( &(Scr->RastPort), x+nlen, y-2, x+len+2, y+bP->Font.ta_YSize+2 );
SetAPen( &(Scr->RastPort), 1 );
}
len = nlen;
if(!( count%(51-bP->Speed ))) {
ScrollRaster( &(Scr->RastPort), dx, dy, x-2, y-2, x+len+2, y+bP->Font.ta_YSize+2 );
x -= dx; y -= dy;
if( x < 3 ) dx = -1;
else if( x > Wid-len-3 ) dx = 1;
if( y < 3 ) dy = -1;
else if( y > Hei-bP->Font.ta_YSize-3 ) dy = 1;
}
}
SetSignal( 0L, SIGBREAKF_CTRL_C );
if( font ) CloseFont( font );
UnblankMousePointer();
CloseScreen( Scr );
}